﻿//////////////////////////////////////////////////////////////////////
// <copyright file=Circle.cs">
//     Copyright (c) 2010
//     Released under  GNU GENERAL PUBLIC LICENSE
//     http://dev.perl.org/licenses/gpl1.html
// </copyright>
// <date> 3/7/2010 1:58:08 PM </date>
// <author> B. Endrovski </author>
// <web> http://furiouspixels.blogspot.com/ </web>
//////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Drawing;

namespace Curves
{
	public class Circle : Curve
	{
		[Category("Shape")]
		public float Radius
		{
			get { return radius; }
			set { radius = value; }
		}
		private float radius = 200;
		
		[Category("Shape")]
		public Point Center
		{
			get { return center; }
			set { center = value; }
		}
		private Point center = new Point(240, 240);

		public Circle()
		{
			samples = 64;
		}

		public override PointF[] GetCurve()
		{

			PointF[] curve = new PointF[samples + 1];
			//
			double dt = 2.0 * Math.PI / samples;
			double t = 0.0;
			for (int i = 0; i <= samples; i++)
			{
				float x = center.X + radius * (float)Math.Sin(t);
				float y = center.Y + radius * (float)Math.Cos(t);
				curve[i] = new PointF(x, y);
				//
				t += dt;
			}
			//
			return curve;
		}
	}
}
